#ifndef BEZIER_H
#define BEZIER_H

// This is a base class of CSGPachNode and CSGSolidNode

#include "stdlib.h"

class Bezier
{
public:
    Bezier();
    Bezier(const Bezier& b);
    Bezier(int _dimDomain, int _dimSpace, int *_ctrlPoly, double **_ctrlPts = NULL);
    virtual ~Bezier();

    // draw
    void drawCtrlPolygon(bool fill = false);

    // set & get
    double *ctrlPt(int *index);
    void ctrlPtIndex(int index, int *pos);
    int ctrlPtIndex(int *index);
    int getNumOfCtrlPts();

    int ptIndex(int *index, int *dim);
    double *getPt(int *index, int *dim, double **pts);

    // computation
    void casteljau(int domainAxis, double t, Bezier* subB1, Bezier* subB2);

    // operation
    Bezier& operator = (const Bezier& b);

    // test

protected:
    void allocateCtrlPts();
    double** allocateCtrlPts(int num);
    void releaseCtrlPts();
    void releaseCtrlPts(double **ctrlPts, int num);
    void release();

protected:
    int dimSpace;
    int dimDomain;
    int *dimCtrlPoly;
    int numCtrlPts;
    double **ctrlPts;
};

#endif // BEZIER_H
